home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 8
/
FM Towns Free Software Collection 8.iso
/
t_os
/
artemis
/
artsrc2
/
extwild.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-01
|
1KB
|
47 lines
/*
extwild.c
ワイルドカードの展開
*/
#include <stdio.h>
#include <dos.h>
#include <string.h>
#include <malloc.h>
#include <ryosuke.h>
int extwildcard(char *wildcard, char *namebuf[], int maxnames)
/* 返値 : 見つかったファイルの個数(≦maxnames) */
/* 各ファイルネームを格納するための領域は逐一 malloc される。 */
{
char *p,path[80],buf[80];
struct find_t fdat;
bool first;
uint ret;
int foundnum;
/* wildcard から パス名部分を取り出す */
strcpy(path,wildcard);
if ((p = strrchr(path, '\\')) != NULL)
*++p = '\0';
else
path[0] = '\0';
for (first=YES,foundnum=0; foundnum < maxnames; first=NO,foundnum++) {
if (first)
ret = _dos_findfirst(wildcard, _A_NORMAL, &fdat);
else
ret = _dos_findnext(&fdat);
if (ret != 0)
break;
strcpy(buf, path);
strcat(buf, fdat.name);
if ((namebuf[foundnum] = malloc(strlen(buf)+1)) == NULL)
break;
else
strcpy(namebuf[foundnum], buf);
}
return foundnum;
}